import pymysql
import requests
from flask import Flask

conn = pymysql.connect(
    host="127.0.0.1",
    port=3306,
    user="root",
    password="123456",
    database="tlias",
    charset="utf8"
)

cursor = conn.cursor()

app = Flask(__name__)


@app.route("/")
def hello_world():
    sql = "select * from dept"
    result = cursor.execute(sql)
    # 得到查询后的真正结果
    r = cursor.fetchall()
    return str(r)


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=1234)
    # 这里指定了地址和端口号.
